/*
 * Copyright (c) 2012 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.coms514.scheduleme;

import com.google.api.client.util.Objects;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.EventDateTime;

class TodayEventInfo implements Comparable<TodayEventInfo>, Cloneable {

	static final String FIELDS = "id,summary";
	static final String FEED_FIELDS = "items(" + FIELDS + ")";

	String id;
	String summary;
	boolean selected = false;
	EventDateTime start;
	EventDateTime end;
	String location;

	TodayEventInfo() {
	}

	TodayEventInfo(Event event) {
		update(event);
	}

	public String getId() {
		return this.id;
	}

	public String getSummary() {
		return this.summary;
	}
	
	public boolean getSelected() {
		return this.selected;
	}
	
	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
	/****/
	public EventDateTime getStart() {
		return this.start;
	}
	
	public EventDateTime getEnd() {
		return this.end;
	}

	public String getLocation() {
		return this.location;
	}
	/****/
	
	@Override
	public String toString() {
		return Objects.toStringHelper(TodayEventInfo.class).add("id", id).add("summary", summary)
				.toString();
	}

	public int compareTo(TodayEventInfo other) {
		return summary.compareTo(other.summary);
	}

	@Override
	public TodayEventInfo clone() {
		try {
			return (TodayEventInfo) super.clone();
		} catch (CloneNotSupportedException exception) {
			// should not happen
			throw new RuntimeException(exception);
		}
	}

	void update(Event event) {
		id = event.getId();
		summary = event.getSummary();
		start = event.getStart();
		end = event.getEnd();
		location = event.getLocation();
	}
}
